package com.ruoyi.web.controller.operation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.vo.OrderCommissionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwRightsOrderCommission;
import com.ruoyi.system.service.IGwRightsOrderCommissionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台权益佣金Controller
 * 
 * @author ruoyi
 * @date 2025-05-12
 */
@Api(description = "平台运营管理-代理商佣金结算")
@RestController
@RequestMapping("/system/orderCommission")
public class GwRightsOrderCommissionController extends BaseController
{
    @Autowired
    private IGwRightsOrderCommissionService gwRightsOrderCommissionService;

    /**
     * 查询平台权益佣金列表
     */
    @ApiOperation("查询平台权益佣金列表-分页")
    @GetMapping("/list")
    public TableDataInfo list(GwRightsOrderCommission gwRightsOrderCommission)
    {
        startPage();
        List<OrderCommissionVO> list = gwRightsOrderCommissionService.selectList(gwRightsOrderCommission);
        return getDataTable(list);
    }

    /**
     * 导出平台权益佣金列表
     */
    @ApiOperation("导出代理商佣金结算列表")
    @PreAuthorize("@ss.hasPermi('system:orderCommission:export')")
    @Log(title = "平台权益佣金", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwRightsOrderCommission gwRightsOrderCommission)
    {
        List<OrderCommissionVO> list = gwRightsOrderCommissionService.selectList(gwRightsOrderCommission);
        ExcelUtil<OrderCommissionVO> util = new ExcelUtil<OrderCommissionVO>(OrderCommissionVO.class);
        util.exportExcel(response, list, "代理商佣金结算");
    }

    /**
     * 获取平台权益佣金详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:orderCommission:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwRightsOrderCommissionService.selectGwRightsOrderCommissionById(id));
    }

    /**
     * 新增平台权益佣金
     */
    @PreAuthorize("@ss.hasPermi('system:orderCommission:add')")
    @Log(title = "平台权益佣金", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwRightsOrderCommission gwRightsOrderCommission)
    {
        return toAjax(gwRightsOrderCommissionService.insertGwRightsOrderCommission(gwRightsOrderCommission));
    }

    /**
     * 修改平台权益佣金
     */
    @PreAuthorize("@ss.hasPermi('system:orderCommission:edit')")
    @Log(title = "平台权益佣金", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwRightsOrderCommission gwRightsOrderCommission)
    {
        return toAjax(gwRightsOrderCommissionService.updateGwRightsOrderCommission(gwRightsOrderCommission));
    }

    /**
     * 删除平台权益佣金
     */
    @PreAuthorize("@ss.hasPermi('system:orderCommission:remove')")
    @Log(title = "平台权益佣金", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gwRightsOrderCommissionService.deleteGwRightsOrderCommissionByIds(ids));
    }
}
